package com.jing.product.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jing.common.core.domain.R;
import com.jing.common.core.web.controller.BaseController;
import com.jing.product.domain.po.ProductCategory;
import com.jing.product.mapper.TestMapper;
import com.jing.product.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author：HaoYunde
 * @Package：com.jing.product.controller
 * @Project：Jing
 * @name：TestController
 * @Date：2024/6/6 19:44
 */
@RestController
@RequestMapping("/test")
public class TestController extends BaseController {
    @Autowired
    private TestService testService;
    @Autowired
    private TestMapper testMapper;


    /**
     * 查询列表
     */
    @RequestMapping("/list")
    public R list() {
        List<ProductCategory> list = testService.list();
        return R.ok(list);
    }


     /**
     * 模糊查询列表
     */
    @RequestMapping("/listByName")
    public R listByName(@RequestParam String name) {
        // 创建一个QueryWrapper实例
        QueryWrapper<ProductCategory> queryWrapper = new QueryWrapper<>();
        // 使用like方法进行模糊查询，第一个参数是数据库字段名，第二个参数是模糊查询的值
        queryWrapper.like("name", name);
        List<ProductCategory> list = testMapper.selectList(queryWrapper);
        return R.ok(list);
    }





}
